package com.qualitair44.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

import com.qualitair44.R;

public class QualitAir44Activity extends TabActivity {



	/**
	 * Called when the activity is first created.
	 * @param savedInstanceState If the activity is being re-initialized after 
	 * previously being shut down then this Bundle contains the data it most 
	 * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.main);

		// Resources res = getResources(); // Resource object to get Drawables   
		TabHost tabHost = getTabHost();  // The activity TabHost  
		TabHost.TabSpec spec;  // Resusable TabSpec for each tab    
		Intent intent;  // Reusable Intent for each tab   

		// Tab for my station
		intent = new Intent().setClass(this, MyStationActivity.class);      
		spec = tabHost.newTabSpec("MySation").setIndicator("Ma station"); 
		spec.setContent(intent);
		tabHost.addTab(spec);

		// Tab for History
		intent = new Intent().setClass(this, HistoryActivity.class); 
		spec = tabHost.newTabSpec("History").setIndicator("Historique"); 
		spec.setContent(intent);
		tabHost.addTab(spec); 

		// Tab for FAQ
		intent = new Intent().setClass(this, FAQActivity.class); 
		spec = tabHost.newTabSpec("FAQ").setIndicator("FAQ"); 
		spec.setContent(intent);
		tabHost.addTab(spec); 

		// Tab for Quizz
		if(getIntent().getIntExtra("numQuestion", -1) > -1){
			intent = new Intent().setClass(this, QuizzActivity.class); 
			spec = tabHost.newTabSpec("Quizz").setIndicator("Quizz"); 
			spec.setContent(intent);
			tabHost.addTab(spec);
			intent.putExtra("numQuestion", getIntent().getIntExtra("numQuestion", 0));
			intent.putExtra("score", getIntent().getIntExtra("score", 0));
			spec.setContent(intent);
			tabHost.setCurrentTab(3);
		} 


		else {
			intent = new Intent().setClass(this, QuizzActivity.class); 
			spec = tabHost.newTabSpec("Quizz").setIndicator("Quizz"); 
			spec.setContent(intent);
			tabHost.addTab(spec); 
			tabHost.setCurrentTab(0);
		}


	}

}

